KfinanceRails2::Application.routes.draw do

  root :to => "welcome#index"
  match '/authentication_token' => 'users#authentication_token'

  match '/suggest/:text' => 'welcome#suggest'
  match '/suggestion/:text' => 'suggestion#suggest'
  match '/wish_list_suggestion/:text' => 'suggestion#wish_list_suggestion'

  resources :token_authentications, :only => [:create, :destroy]
  resources :authentications

  match '/auth/:provider' => 'authentications#create'
  match '/auth/:provider/callback' => 'authentications#create'

  devise_for :users, :controllers => {:registrations => 'registrations', :sessions => "session" }

  authenticate :user do
    root :to => 'twee#index'

    get 'index' => 'twee#index'
    post 'add_operation' => 'twee#add_operation'
    post 'tweet_operation' => 'twee#tweet_operation'
    post 'del_operation' => 'twee#del_operation'
    post 'update_operation' => 'twee#update_operation'


    resources :wallets do
      resources :amounts
    end

    resources :operations do
      resources :amount_changes

      get 'report'
    end

    resources :tags, :only => [:index]

    get "currencies"           => "currency#index"
    get "currencies/all_codes" => "currency#all_codes"
    get "currencies/exchange_rates" => "currency_exchange_rate#rates"

    get    "wish_list(/:name)"                  => "wish_lists#show"
    post   "wish_list"                          => "wish_lists#update"
    delete "wish_list/:name"                    => "wish_lists#destroy"

    get    "wish_list/suggest/popular(/:count)" => "wish_lists_suggestions#popular", :defaults => {:count => 20}, :constraints => { :count => /\d{1,3}/ }
    get    "wish_list/suggest/:text(/:count)"   => "wish_lists_suggestions#suggest", :defaults => {:count => 20}, :constraints => { :count => /\d{1,3}/ }

    resources :scheduled_records
    post 'scheduled_records/destroy/:id' => "scheduled_records#destroy"

  end

end

